← Back to issue list

Snapcraft fails to build snap if Snapcraft itself is installed using `snap try`

View original Launchpad issue

Metadata

Project
snapcraft (launchpad)
Number
#2014963
Type
issue
State
open
Author
~brlin
Labels
Created
2023-04-01 14:07:50.460548+00:00
Updated
2023-04-01 14:16:32.244880+00:00
Closed

Current evaluation

No evaluation has been recorded for this issue yet.

Issue body

I'm testing a small change in the Snapcraft source tree so I make /snap/snapcraft/current writable by using OverlayFS by using the following command: ``` mkdir {upper,work,merged} sudo mount -t overlay overlay -o "lowerdir=/snap/snapcraft/current,upperdir=upper,workdir=work" merged ``` made my change, and install it in try mode using: ``` sudo snap try --classic merged ``` However, when testing the change using a third party snap recipe, Snapcraft errored with the following output: ``` OCRmyPDF - A utility to add an OCR text layer to scanned PDF files, allowing them to be searched on  master via 🐍 v3.8.10 took 5s ❯ snapcraft build ocrmypdf --use-lxd --shell-after --debug Launching a container. Waiting for container to be ready Waiting for network to be ready... Sorry, an error occurred in Snapcraft: 400 Client Error: Bad Request for url: http+unix://%2Frun%2Fsnapd.socket/v2/snaps/snapcraft/file We would appreciate it if you anonymously reported this issue. No other data than the traceback and the version of snapcraft in use will be sent. Would you like to send this error data? (Yes/No/Always/View) [no]: yes Thank you, sent. You can find the traceback in file '/tmp/tmpcfxdmxwa/trace.txt'. OCRmyPDF - A utility to add an OCR text layer to scanned PDF files, allowing them to be searched on  master via 🐍 v3.8.10 took 15s ❯ cat /tmp/tmpcfxdmxwa/trace.txt Traceback (most recent call last):   File "/snap/snapcraft/x1/lib/python3.8/site-packages/snapcraft/cli.py", line 243, in run     _run_dispatcher(dispatcher)   File "/snap/snapcraft/x1/lib/python3.8/site-packages/snapcraft/cli.py", line 219, in _run_dispatcher     dispatcher.run()   File "/snap/snapcraft/x1/lib/python3.8/site-packages/craft_cli/dispatcher.py", line 448, in run     return self._loaded_command.run(self._parsed_command_args)   File "/snap/snapcraft/x1/lib/python3.8/site-packages/snapcraft/commands/lifecycle.py", line 132, in run     parts_lifecycle.run(self.name, parsed_args)   File "/snap/snapcraft/x1/lib/python3.8/site-packages/snapcraft/parts/lifecycle.py", line 178, in run     yaml_data = process_yaml(snap_project.project_file)   File "/snap/snapcraft/x1/lib/python3.8/site-packages/snapcraft/parts/lifecycle.py", line 141, in process_yaml     yaml_data = yaml_utils.load(yaml_file)   File "/snap/snapcraft/x1/lib/python3.8/site-packages/snapcraft/parts/yaml_utils.py", line 92, in load     raise errors.LegacyFallback("base is not core22") snapcraft.errors.LegacyFallback: base is not core22 During handling of the above exception, another exception occurred: Traceback (most recent call last):   File "/snap/snapcraft/x1/lib/python3.8/site-packages/snapcraft_legacy/cli/legacy.py", line 27, in legacy_run     run()   File "/snap/snapcraft/x1/lib/python3.8/site-packages/click/core.py", line 1130, in __call__     return self.main(*args, **kwargs)   File "/snap/snapcraft/x1/lib/python3.8/site-packages/click/core.py", line 1055, in main     rv = self.invoke(ctx)   File "/snap/snapcraft/x1/lib/python3.8/site-packages/click/core.py", line 1657, in invoke     return _process_result(sub_ctx.command.invoke(sub_ctx))   File "/snap/snapcraft/x1/lib/python3.8/site-packages/click/core.py", line 1404, in invoke     return ctx.invoke(self.callback, **ctx.params)   File "/snap/snapcraft/x1/lib/python3.8/site-packages/click/core.py", line 760, in invoke     return __callback(*args, **kwargs)   File "/snap/snapcraft/x1/lib/python3.8/site-packages/snapcraft_legacy/cli/lifecycle.py", line 337, in build     _execute(steps.BUILD, parts, **kwargs)   File "/snap/snapcraft/x1/lib/python3.8/site-packages/snapcraft_legacy/cli/lifecycle.py", line 144, in _execute     with build_provider_class(   File "/snap/snapcraft/x1/lib/python3.8/site-packages/snapcraft_legacy/internal/build_providers/_base_provider.py", line 87, in __enter__     self.create()   File "/snap/snapcraft/x1/lib/python3.8/site-packages/snapcraft_legacy/internal/build_providers/_lxd/_lxd.py", line 284, in create     self.launch_instance()   File "/snap/snapcraft/x1/lib/python3.8/site-packages/snapcraft_legacy/internal/build_providers/_base_provider.py", line 263, in launch_instance     self._setup_snapcraft()   File "/snap/snapcraft/x1/lib/python3.8/site-packages/snapcraft_legacy/internal/build_providers/_lxd/_lxd.py", line 482, in _setup_snapcraft     super()._setup_snapcraft()   File "/snap/snapcraft/x1/lib/python3.8/site-packages/snapcraft_legacy/internal/build_providers/_base_provider.py", line 510, in _setup_snapcraft     snap_injector.apply()   File "/snap/snapcraft/x1/lib/python3.8/site-packages/snapcraft_legacy/internal/build_providers/_snap.py", line 392, in apply     snap.push_host_snap(file_pusher=self._file_pusher)   File "/snap/snapcraft/x1/lib/python3.8/site-packages/snapcraft_legacy/internal/build_providers/_snap.py", line 141, in push_host_snap     host_snap_repo.local_download(   File "/snap/snapcraft/x1/lib/python3.8/site-packages/snapcraft_legacy/internal/repo/snaps.py", line 199, in local_download     snap_file_iter = _get_local_snap_file_iter(self.name, chunk_size=1024)   File "/snap/snapcraft/x1/lib/python3.8/site-packages/snapcraft_legacy/internal/repo/snaps.py", line 365, in _get_local_snap_file_iter     snap_file.raise_for_status()   File "/snap/snapcraft/x1/lib/python3.8/site-packages/requests/models.py", line 1021, in raise_for_status     raise HTTPError(http_error_msg, response=self) requests.exceptions.HTTPError: 400 Client Error: Bad Request for url: http+unix://%2Frun%2Fsnapd.socket/v2/snaps/snapcraft/file ``` Here's the response of http+unix://%2Frun%2Fsnapd.socket/v2/snaps/snapcraft/file: ``` ❯ http http+unix://%2Frun%2Fsnapd.socket/v2/snaps/snapcraft/file HTTP/1.1 400 Bad Request Content-Length: 133 Content-Type: application/json Date: Sat, 01 Apr 2023 13:53:04 GMT {     "result": {         "message": "cannot download file for try-mode snap \"snapcraft\""     },     "status": "Bad Request",     "status-code": 400,     "type": "error" } ``` It seems that Snapcraft tries to inject itself's snap package into the built environment, and fails due to the package file doesn't exist in the first place. It would be great if Snapcraft could detect such a situation and workaround it somehow(like pack itself to a new snap package and inject that package instead), making testing small code changes possible, or at least error in a friendlier, more specific, error message.

Evaluation history

No evaluation history available.